package com.hp.bon.sgw;

import org.slf4j.LoggerFactory;

/**
 * BON Common Constants
 */
public class Constants {

	final public static org.slf4j.Logger LOG = LoggerFactory.getLogger("SGW");
	/**
	 * 接入接口类型
	 */
	public static final int SGW_GATEWAY_TYPE_DCC = 1;
	public static final int SGW_GATEWAY_TYPE_SCSP = 2;
	public static final int SGW_GATEWAY_TYPE_WS = 3;

	/**
	 * 传输方向 : 计费网内发计费网外OUT
	 */
	public static final int TRANS_DIRECTION_OUT = 0;
	/**
	 * 传输方向 : 计费网外到计费网内请求IN
	 */
	public static final int TRANS_DIRECTION_IN = 1;
	/**
	 * 传输方向 : 网外到网外 (集团)
	 */
	public static final int TRANS_DIRECTION_OO = 2;

	public static final int PRIORITY_DEFAULT = 1000;

	// Diameter Protocol Code - Result
	public static final int DIAMETER_RESULT_MULTI_ROUND_AUTH = 1001;

	public static final int DIAMETER_RESULT_SUCCESS = 2001;

	public static final int DIAMETER_RESULT_LIMITED_SUCCESS = 2002;

	// OCS
	public static final int DIAMETER_RESULT_BALANCE_HAVE_LITTLE_MONEY = 2202;

	public static final int DIAMETER_RESULT_COMMAND_UNSUPPORTED = 3001;

	public static final int DIAMETER_RESULT_UNABLE_TO_DELIVER = 3002;

	public static final int DIAMETER_RESULT_REALM_NOT_SERVED = 3003;

	public static final int DIAMETER_RESULT_TOO_BUSY = 3004;

	public static final int DIAMETER_RESULT_LOOP_DETECTED = 3005;

	public static final int DIAMETER_RESULT_REDIRECT_INDICATION = 3006;

	public static final int DIAMETER_RESULT_APPLICATION_UNSUPPORTED = 3007;

	public static final int DIAMETER_RESULT_INVALID_HDR_BITS = 3008;

	public static final int DIAMETER_RESULT_INVALID_AVP_BITS = 3009;

	public static final int DIAMETER_RESULT_UNKNOWN_PEER = 3010;
	
	public static final int DIAMETER_RESULT_DIAMETER_TIMEOUT = 3011;//判断下游超时后，构造CCA返回上游

	public static final int DIAMETER_RESULT_AUTHENTICATION_REJECTED = 4001;

	public static final int DIAMETER_RESULT_OUT_OF_SPACE = 4002;

	public static final int DIAMETER_RESULT_ELECTION_LOST = 4003;

	public static final int DIAMETER_RESULT_AVP_UNSUPPORTED = 5001;

	public static final int DIAMETER_RESULT_UNKNOWN_SESSION_ID = 5002;

	public static final int DIAMETER_RESULT_AUTHORIZATION_REJECTED = 5003;

	public static final int DIAMETER_RESULT_INVALID_AVP_VALUE = 5004;

	public static final int DIAMETER_RESULT_MISSING_AVP = 5005;

	public static final int DIAMETER_RESULT_RESOURCES_EXCEEDED = 5006;

	public static final int DIAMETER_RESULT_CONTRADICTING_AVPS = 5007;

	public static final int DIAMETER_RESULT_AVP_NOT_ALLOWED = 5008;

	public static final int DIAMETER_RESULT_AVP_OCCURS_TOO_MANY_TIMES = 5009;

	public static final int DIAMETER_RESULT_NO_COMMON_APPLICATION = 5010;

	public static final int DIAMETER_RESULT_UNSUPPORTED_VERSION = 5011;

	public static final int DIAMETER_RESULT_UNABLE_TO_COMPLY = 5012;

	public static final int DIAMETER_RESULT_INVALID_BIT_IN_HEADER = 5013;

	public static final int DIAMETER_RESULT_INVALID_AVP_LENGTH = 5014;

	public static final int DIAMETER_RESULT_INVALID_MESSAGE_LENGTH = 5015;

	public static final int DIAMETER_RESULT_INVALID_AVP_BIT_COMBO = 5016;

	public static final int DIAMETER_RESULT_NO_COMMON_SECURITY = 5017;

	public static final int DIAMETER_SERVICE_RESULT_SUCCESS = 0;

	public static final int DIAMETER_AVP_DES_REALM = 283;
	public static final int DIAMETER_AVP_AUTH_APP_ID = 258;
	public static final int DIAMETER_AVP_Acct_APP_ID = 259;
	// Diameter Protocal Code - Vender
	static public final int DIAMETER_VENDOR_CT = 81000;

	static public final int DIAMETER_VENDOR_3GPP = 10415;

	// Diameter Protocal Code - Command Code
	static public final int DIAMETER_CMD_CCR = 272;

	/**
	 * 虚拟的SGW_DATA_ROOT AVP code
	 */
	static public final int SGW_DATA_ROOT_AVP = 99999;
	static public final String SGW_XML_ROOT_NAME = "SGW_DATA_ROOT";
	// Diameter Protocal Code - AVP Code
	public static final int DIAMETER_AVP_OUT_PLATFORM_DESC = 80409;
	public static final int DIAMETER_AVP_SERVICE_FLOW_ID = 80172;
	public static final int DIAMETER_AVP_EVENT_TIMESTAMP = 55;
	public static final int DIAMETER_AVP_CC_REQUEST_TYPE = 416;
	public static final int DIAMETER_AVP_CC_REQUEST_ACTION = 436;
	public static final int DIAMETER_AVP_CC_REQUEST_NUMBER = 415;
	public static final int DIAMETER_AVP_SESSION_ID = 263;
	public static final int DIAMETER_AVP_ORIGIN_HOST = 264;
	public static final int DIAMETER_AVP_ORIGIN_STATE_ID = 278;
	public static final int DIAMETER_AVP_Route_Record = 282;
	public static final int DIAMETER_AVP_Proxy_Info = 284;
	public static final int DIAMETER_AVP_DEST_HOST = 293;
	public static final int DIAMETER_AVP_ORIGIN_REALM = 296;
	public static final int DIAMETER_AVP_Termination_Cause = 295;
	public static final int DIAMETER_AVP_RESULT_CODE = 268;
	public static final int DIAMETER_AVP_SERVICE_RESULT_CODE = 20631;
	public static final int DIAMETER_AVP_SERVICE_CONTEXT_ID = 461;
	public static final int DIAMETER_AVP_SERVICE_INFOMATION = 873;
	public static final int DIAMETER_AVP_NET_CTRL_INFOMATION = 80020;
	public static final int DIAMETER_AVP_NE_INFOMATION = 80021;
	public static final int DIAMETER_AVP_NE_HOST = 80024;
	public static final int DIAMETER_AVP_NE_TYPE = 80029;
	public static final int DIAMETER_AVP_NE_IP = 80025;
	public static final int DIAMETER_AVP_NE_PORT = 80027;
	public static final int DIAMETER_AVP_Network_Latency = 80038;
	public static final int DIAMETER_AVP_Priority = 80037;
	public static final int DIAMETER_AVP_Update_Action = 80036;
	public static final int DIAMETER_AVP_SERVICE_CONTEXT_INFOMATION = 80031;
	public static final int DIAMETER_AVP_DATA_INFORMATION = 80400;
	public static final int DIAMETER_AVP_DATA_TABLE_SIMPLE_ROW = 80406;
	public static final int DIAMETER_AVP_Congestion_Level = 80039;
	public static final int DIAMETER_AVP_Disconnect_Cause = 80040;
	public static final int DIAMETER_AVP_Forward_Info = 80047;
	public static final int DIAMETER_AVP_SELF_HOST = 80048;
	public static final int DIAMETER_AVP_DOWNSTREAM_HOST = 80049;
	public static final int DIAMETER_AVP_RESPONSE_TIME = 80050;
	public static final int DIAMETER_AVP_SERVICE_CODE = 80208;
	
	public static final int DIAMETER_AVPGROUP_ACCESS_INFORMATION = 80208;
	public static final int DIAMETER_AVPGROUP_SERVICE_ABSTRACT_INFORMATION = 80208;
	public static final int DIAMETER_AVPGROUP_CONTROL_INFORMATION = 80208;

	public static final int DIAMETER_AVP_Message_Size = 80041;
	public static final int DIAMETER_AVP_Para_Field_Result = 80407;
	
	public static final int DIAMETER_AVP_Destination_Id = 5051;	

	public static final int DIAMETER_AVP_SYNC_CODE = 80067;

	public static final int DIAMETER_AVP_AUDIT_KEY = 80071;

	public static final int DIAMETER_AVP_DATA_TABLE_NAME = 80492;
	
	public static final int DIAMETER_AVP_NEXT_HOST = 80023;
	public static final int DIAMETER_AVP_Msg_Recv_Req_Time = 80068;

	// Diameter Protocol Code - AVP Code Value
	static public final int DIAMETER_AVP_CC_REQUEST_TYPE__INIT = 1;

	static public final int DIAMETER_AVP_CC_REQUEST_TYPE__UPDATE = 2;

	static public final int DIAMETER_AVP_CC_REQUEST_TYPE__TERM = 3;

	static public final int DIAMETER_AVP_CC_REQUEST_TYPE__EVENT = 4;

	static public final int DIAMETER_AVP_NE_TYPE__BUSINESSNE = 2;

	static public final int DIAMETER_AVP_CC_REQUEST_ACTION_TYPE__NC = 111;

	static public final int DIAMETER_AVP_CC_REQUEST_ACTION_TYPE__BS = 113;

	static public final int DIAMETER_AVP_CC_REQUEST_ACTION_TYPE__NM = 115;

	public static final int DIAMETER_APPLICATION_COMMON = 0;

	public static final int DIAMETER_APPLICATION_CREDIT_CONTROL = 4;

	public static final int DIAMETER_AVP_VC_Information = 20603;
	public static final int DIAMETER_AVP_Req_Serial = 20635;
	public static final int DIAMETER_AVP_Voucher_Pin = 20615;
	public static final int DIAMETER_AVP_Calling_Number = 20602;
	public static final int DIAMETER_AVP_Destination_Account = 20608;
	public static final int DIAMETER_AVP_Recharge_Service_Type = 20648;
	public static final int DIAMETER_AVP_Access_Type = 20605;
	public static final int DIAMETER_AVP_Access_Home = 20654;
	public static final int DIAMETER_AVP_Balance_Type = 20655;
	public static final int DIAMETER_AVP_Destination_Balance_Unit = 20637;
	public static final int DIAMETER_AVP_Voucher_Id = 20632;
	public static final int DIAMETER_AVP_Voucher_Value = 20633;
	public static final int DIAMETER_AVP_Voucher_Expiration_Time = 20646;
	public static final int DIAMETER_AVP_Prolong_Days = 20640;
	public static final int DIAMETER_AVP_Destination_Type = 20607;
	public static final int DIAMETER_AVP_Destination_Attr = 20647;
	public static final int DIAMETER_AVP_Destination_Attr_Detail = 20667;
	public static final int DIAMETER_AVP_Destination_Area_Code = 50207;
	public static final int DIAMETER_AVP_Destination_Bonus_Info = 20619;
	public static final int DIAMETER_AVP_Destination_Bonus_Unit = 20634;
	public static final int DIAMETER_AVP_Destination_Bonus_Amount = 20620;
	public static final int DIAMETER_AVP_Destination_Bonus_Start_Time = 20621;
	public static final int DIAMETER_AVP_Destination_Bonus_Expiration_Time = 20622;
	public static final int DIAMETER_AVP_Area_Code = 50207;
	public static final int DIAMETER_AVP_RechargeAmount = 20658;
	public static final int DIAMETER_AVP_RechargeTime = 20651;
	public static final int DIAMETER_AVP_OperationCode = 20659;
	public static final int DIAMETER_AVP_RechargeUserType = 20650;
	public static final int DIAMETER_AVP_UserBalanceSystem = 20660;
	public static final int DIAMETER_AVP_UserSystem = 20663;
	public static final int DIAMETER_AVP_Ori_Session_Id = 20656;
	public static final int DIAMETER_AVP_Res_Serial = 20636;
	public static final int DIAMETER_AVP_Balance_Info = 20638;
	public static final int DIAMETER_AVP_Destination_Balance = 20617;
	public static final int DIAMETER_AVP_Destination_Effective_Time = 20609;
	public static final int DIAMETER_AVP_Destination_Expiration_Time = 20618;

	public static final int DIAMETER_AVP_srvPlatfrmID = 80105;
	public static final int DIAMETER_AVP_outPlatfrmDesc = 80409;
	public static final int DIAMETER_AVP_Service_Flow_Id = 80172;

	/**
	 * QueryHomeAreaByAccNbr.HSS 归属地查询
	 */
	public static final int DIAMETER_AVP_AccNbr = 80125;
	public static final int DIAMETER_AVP_DestinationAttr = 5055;
	public static final int DIAMETER_AVP_HomeAreaCode = 80615;
	public static final int DIAMETER_AVP_Provincecode = 81105;

	/**
	 * 安全框架
	 * 
	 * @author sunhaiy
	 * 
	 */

	public static class ResultCode {
		public static final int APP = -1;
		public static final int DB = -100;
		public static final int SUCCESS = 0;
		public static final int USER_NOT_EXIST = 11001;
		public static final int USER_LOCKED = 11002;
		public static final int PASSWORD_ERROR = 11003;
		public static final int IP_NOT_MATCH = 11004;
		public static final int CAPABILITY_NOT_EXIST = 11005;
		public static final int CAPABILITY_NO_AUTH = 11006;
		public static final int SYSTEM_BUSY = 11007;
		public static final int CONNECT_EXIST = 11008;
		public static final int UNKNOW_MSG = 11009;
		public static final int UNKNOW_ERR = 11300;
		/**
		 * 连续3次鉴权失败
		 */
		public static final int AUTH_ERROR_3TIMES = 11020;
		/**
		 * 单个包大小超过阀值
		 */
		public static final int MESSAGE_SIZE_OVER = 11034;

		/**
		 * 数字签名失败
		 */
		public static final int NumIdiograph_ERROR = 11101;

		/**
		 * 非法关键字
		 */
		public static final int ILEAGAL_KEYWORD_ERROR = 11102;
		/**
		 * 缺少必填字段
		 */
		public static final int MISSING_TAG = 11104;
		/**
		 * 流控
		 */
		public static final int FLUX_WARNING = 11032;
		public static final int FLUX_DISCONNECT = 11033;
		
		public static final int FLUX_PROV =11036;
		public static final int FLUX_CAPA_RESULT =11037;

		/**
		 * 字段值错误
		 */
		public static final int VALUE_ERROR = 11105;
		/**
		 * 未定义的标签或字段
		 */
		public static final int UNKNOW_TAG = 11106;

		/**
		 * 格式转换错误：例如CCR中要求某一字段的类型为Grouped类型，外部系统请求中将其作为值字段填
		 */
		public static final int TYPE_ERROR = 11107;
		/**
		 * 收到重复包。SOAP/SCSP协议用 MID + REPTAG 字段判重
		 */
		public static final int DUP_MESSAGE = 11108;
		/**
		 * 没有查到对应的SR（待定）
		 */
		public static final int CANNOT_FIND_SR = 11201;
		/**
		 * BON不可用（外部访问内部） 如计费网内路由异常
		 */
		public static final int BON_CANNOT_USE = 11202;
		/**
		 * 等待BON返回消息超时（如果需要返回应答）
		 */
		public static final int BON_TIMEOUT = 11203;
		/**
		 * 外部网元不可用
		 */
		public static final int NE_CANNOT_USE = 11204;
		/**
		 * 外部网元没有及时回复应答(外部网元超时) 11205
		 */
		public static final int NE_TIMEOUT = 11205;
		/**
		 * BON 返回错误（A接口主动请求，B接口返回的信息在协议级别错误，SGW要返回给A接口的信息中RC字段填写）
		 */
		public static final int BON_ERROR = 11206;
		/**
		 * SGW消息进程异常
		 */
		public static final int SGW_ERROR = 17006;

		public static final int FLOW_ERROR = 11300;
		public static final int HomeQuery_unConfig = 11301;
		public static final int HomeQuery_ACC_Error = 11302;
		public static final int HomeQuery_ACC_ATTR_Error = 11303;
		public static final int HomeQuery_FAILED = 11304;
		// received response but no request found
		public static final int No_REQ = 11400;
		public static final int Duplicate_ACK = 11401;
		// SGW队列 消息超时
		public static final int QueueMsg_Timeout = 17004;
		// SGW消息队列超阀值
		public static final int Queue_Over_Threshold = 17005;
		
		//用户被列在黑名单
		public static final int Usr_in_Blacklist = 11035;
		
		public static final int rollback_already_rollback = 10023;//目的网元处理回退Session时，已经执行过回退，为重复消息，不需人工介入
		public static final int rollback_donot_need_rollback = 10024;//目的网元处理回退Session时，发现之前没有收到此session，不需人工介入
		public static final int rollback_failed_need_handle = 10025;//目的网元处理回退Session时，执行回退失败，需人工介入
		
		public static final int Capbility_Black_List = 10019;		//服务能力在黑名单
		public static final int Capbility_OutOf_Life_Time = 10099;  //服务能力不在生命周期内
		
	}

	public static class CRMCBResult {

		public static final int WS_SUCCESS = 0;

		public static final int WS_SENDER_FORMAT_ERROR = 401;

		public static final int WS_SENDER_COMMANDCODE_ERROR = 402;

		public static final int WS_SENDER_USERNAME_UNMATCH = 405;

		public static final int WS_SENDER_PASSWARD_UNMATCH = 406;

		public static final int WS_SENDER_SERVICECONTEXTID_UNEXIST = 407;

		public static final int WS_SENDER_MSG_DATAINFO_TOO_LOOG = 408;

		public static final int WS_RCVER_SGW_NOT_AVAIBLE = 500;

		public static final int WS_RCVER_BON_ROUTE_NOT_AVAILABLE = 501;

		public static final int WS_RCVER_BON_MSG_TIMEOUT = 502;

		public static final int WS_RCVER_BON_NOT_UNKNOWN_ERR = 599;

		public static final int WS_RCVER_BON_NE_ERR = 503;

		public static final int WS_RCVER_BON_BIZ_ERROR = 600;

		public static final int WS_SEND_CRM_MSG_TIMEOUT = 520;

		public static final int WS_SEND_CRM_SYS_ERR = 510;
	}

	public static String Param_CompareFilePath = "Param.CompareFilePath";
	public static String Param_CompareFileHour = "Param.CompareFileHour";

	public static String BOSSNM_SysLoc = "BOSSNM.SysLoc";
	public static String BOSSNM_NeTypeId = "BOSSNM.NeTypeId";
	public static String BOSSNM_FilePath = "BOSSNM.FilePath";

	public static class BnmsCongLevel {
		public static final int NO = 0;
		public static final int LIGHT = 1;
		public static final int MIDDLE = 2;
		public static final int HEAVY = 3;
	}

	/**
	 * SGW的在网状态发生改变
	 */
	public static final String SYSLOG_SGWStatusChanged = "sgwstatuschanged";
	/**
	 * SGW的消息转发服务出现异常时。
	 */
	public static final String SYSLOG_MsgProcessError = "msgprocesserror";
	/**
	 * SGW的文件服务出现异常。
	 */
	public static final String SYSLOG_FileProcessError = "fileprocesserror";
	/**
	 * SGW对外部进行流量控制，外部网元流量达到告警阀值时，SGW抛出此通知事件
	 */
	public static final String SYSLOG_FluxContrlWarn = "fluxcontrlwarn";
	/**
	 * SGW的拥塞等级发生变更时，抛出此通知事件。
	 */
	public static final String SYSLOG_BlockChanged = "congestionchanged";
	/**
	 * 当外部网元链路异常时，抛出此通知事件。异常指通信对等端连接状态发生变化，包括网络断开或重复连接等.
	 */
	public static final String SYSLOG_LinkException = "linkexception";
	/**
	 * WS物理连接满
	 */
	public static final String SYSLOG_ConnectionFull = "connectionfull";
	/**
	 * 进程日志
	 */
	public static final String SYSLOG_ProcessLog = "processlog";

	public static class ProcessErrorCode {
		public static final int STATUS_Changed = 200;
		public static final int STATUS_Congestion_NONE = 201;
		public static final int STATUS_Congestion_LIGHT = 202;
		public static final int STATUS_Congestion_SERVER = 203;
		public static final int STATUS_Congestion_DOS = 204;
		public static final int STATUS_OFFLINE = 205;
		public static final int STATUS_ONLINE = 206;
		public static final int STATUS_MAINTANCE = 207;
	}

	public static class CheckType {
		public static final String UP = "U+P";
		public static final String UPI = "U+P+I";
	}

	public static String UniqueMsgIdSpilt = "&";

	public static class SystemStatus {
		public static final char RUNNING = 'R';// -Running/Online

		public static final char MAINTENANCE = 'M';// -Maintenance

		public static final char OFFLINE = 'F';// -Offline/Stopped

		public static final char UNKNOWN = 'X';//
	}

	public static class ChannelType {
		public static final String Channel_DCC = null;
		public static final String Channel_SOAP = null;
	}

	public static class NodeType {
		public static final int NODE_SR = 1;
		public static final int NODE_DCC_BON = 2;// DCC BON网内
		public static final int NODE_DCC_NE = 3;// DCC BON网外
		public static final int NODE_WS_NE = 4;// WS接口的外部网元
		public static final int NODE_SCSP_NE = 5;// SCSP协议网元
		public static final int NODE_SCM = 6;// SR SCM
		public static final int NODE_STM= 7;// SR STM

	}

	// 1--not sure;0 --ok;-1---error; -2 ---timeout;
	public enum CheckStatus {
		NotSure, OK, ERROR, TIMEOUT
		// public static final int NotSure = 1;
		// public static final int OK = 0;
		// public static final int ERROR =-1;
		// public static final int TIMEOUT =-2;
	}

	public static class ConfigPrefix {
		public static final String Persist_Peer = "Diameter.PersistPeers.";
		public static final String Allowed_Peer = "Diameter.AllowedPeers.";
		/**
		 * SGW Node 配置信息
		 */
		public static final String Common_Nodes = "Common.Nodes";
		/**
		 * SGW Channel 信息
		 */
		public static final String Common_Channels = "Common.SGWChannels";
		/**
		 * SGW 能力提供信息
		 */
		public static final String Common_CapaProvideds = "Common.CapaProvideds";
		/**
		 * SGW 能力及能力相关配置信息(能力，能力可访问权限，优先级，超时时间等)
		 */
		public static final String Common_CapabilityCtrlMap="Common.CapabilityCtrlMap";
		
		public static final String Common_DelayForwardConfig = "Common.DelayForwardConfig";
		
		public static final String Common_Xml2AvpMappings = "Common.Xml2AvpMappings";
		
	}

	public static class NodeStatus {
		public static final int OFF_LINE = 0;
		/**
		 * 连接未激活
		 */
		public static final int ON_LINE = 1; 
		/**
		 * 连接已激活
		 */
		public static final int ON_LINE_ACTIVE = 2;
	}

	public static class FluxContralParam {

		public static final int Latency_T1_MS = 20 * 1000;
		public static final int Latency_T2_MS = 35 * 1000;
		public static final double RECV_QUEUE_SIZE_WARNING_RATIO = 0.5;
		public static final double SEND_QUEUE_SIZE_WARNING_RATIO = 0.5;
		public static final double TIMEOUT_WARNING_RATIO = 0.5;

		public static final int MIN_EFFECT_NUM = 2;// 智能分析最小判断条数
	}

	public static class MessageType {
		public static final String WSR = "WSR";
		public static final String WSA = "WSA";
		public static final String CCR = "CCR";
		public static final String CCA = "CCA";
	}

	public static final String SGW_CONFIG_KEY_RMI_IP = "Rmi.Ip";
	public static final String SGW_CONFIG_KEY_RMI_HOSTNAME = "Rmi.HostName";
	public static final String SGW_CONFIG_KEY_RMI_PORT = "Rmi.Port";
	public static final String SGW_CONFIG_KEY_RMI_HTTPPORT = "Rmi.HttpPort";

	public static class FluxLimitUnitType {
		public static final int PERC = 1;
		public static final int NUM = 2;
	}

	public static class EffectiveType {
		public static final String RealTime = "realtime";
		public static final String Reboot = "reboot";
	}
}
